package com.edou.system.controller.admin;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.json.simple.JSONObject;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.edou.base.controller.BaseController;
import com.edou.system.form.SysLogForm;
import com.edou.system.service.ISysLogService;

/**
 * 日志
 * @author winter
 *
 */
@Controller("sysLogController")
@Scope("prototype")
@RequestMapping(value = "/admin/system/sysLog")
public class SysLogController extends BaseController  {



	@Resource(name = "sysLogServiceImpl")
	private ISysLogService sysLogService;
	/** 操作数据集合 */
	@SuppressWarnings("unused")
	private List<String> calcData = new ArrayList<String>();

	@RequestMapping(value = "/index.htm", method = RequestMethod.GET)
	public ModelAndView index(@ModelAttribute SysLogForm model,HttpServletRequest request) {
		ModelAndView view = new ModelAndView();
		view.setViewName("/admin/system/sys_log_index");
		return view;
	}


	/**
	 * 分页查询
	 * @return
	 */
	@RequestMapping(value = "/listSysLogByPage.htm", method = RequestMethod.POST)
	public void listSysLogByPage(@ModelAttribute SysLogForm model, HttpServletRequest request, HttpServletResponse response) {
		try{
			sysLogService.listSysLogByPage(model.getPageResult(),model.getCondition());
			JSONObject root = toPageJson(model.getPageResult(), new String[]{
				"id","createDate","source","type","desc","createId","createBy"
				});
			ajaxPageResult(root, response);
		}catch(Exception ex){
			String msg = "查询日志发生异常："+ex.getMessage();
			logger.error(msg,ex);
		}
		
	}

}
